//
//  SingleFieldCell.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/25/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit

final class SingleFieldCell: UITableViewCell {
    
    private lazy var mainView: OptionItem = {
        let item = OptionItem(showArrow: false)
        return item
    }()
    
    
    public var data: SingleField! {
        didSet {
            mainView.initialize(isSelected: data.isSelected, isSingle: true, title: data.name, isMain: true, textColor: .darkBlueColor)
            mainView.updateSelection(isSelected: data.isSelected)
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func addViews() {
        self.contentView.addSubview(mainView)
        mainView.snp.makeConstraints { (make) in
            make.leading.trailing.equalToSuperview().inset(16)
            make.top.bottom.equalToSuperview().inset(8)
        }
    }
}
